package com.qf.controller;


import com.qf.dto.UserDto;
import com.qf.service.UserService;
import com.qf.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lzy
 * @since 2020-11-28
 */
@RestController
@RequestMapping("/api/user")
@RefreshScope //实时检查配置中心的变量
public class UserController {

    @Autowired
    private UserService userService;


    //查询全部
    @GetMapping("/findAll.do")
    public R findAll() {
        return userService.findAll();
    }

    //登录
    @PostMapping("/login.do")
    public R login(@RequestBody UserDto userDto) {
        return userService.login(userDto);
    }

    //注册
    @PostMapping("/register.do")
    public R register(@RequestBody UserDto userDto) {
        return userService.register(userDto);
    }

    //校验
    @GetMapping("/checkphone.do")
    public R check(String phone){
        return userService.checkPhone(phone);
    }
    //密码找回
    @PostMapping("/findpass.do")
    public R findPass(@RequestBody UserDto userDto){
        return userService.findPass(userDto);
    }
}
